package com.lyn.utils;

import android.util.Log;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;

/**
 * 调用工具栏
 * @author longyn 2023/07/13
 * @version 1.0.0
 */
public class CallUtil {


    /**
     * 打印调用路径
     */
    public static String printCallPath(){
        Throwable throwable = new Throwable();
        StringBuilder sb = new StringBuilder();
        Writer writer = new StringWriter();
        PrintWriter printWriter = new PrintWriter(writer);
        throwable.printStackTrace(printWriter);
        Throwable cause = throwable.getCause();
        while (cause != null) {
            cause.printStackTrace(printWriter);
            cause = cause.getCause();
        }
        printWriter.close();
        String result = writer.toString();
        sb.append(result).append("\n");
        String s = sb.toString();
        Log.d("CallUtil:",s);
        return s;
    }
}
